<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
</head>
<body>

  <div id='app'>
    <home></home>
    <hr>
    <news></news>
  </div>

<template id="tpl">
  <div>
    <h2>我是HOME页</h2>
    <common-head :title="homeTitle" sub_title="我是二级标题"></common-head>
  </div>
</template>
<template id="tpl2">
  <div>
    <h2>我是News页</h2>
    <common-head title="我是news的标题"></common-head>
  </div>
</template>

<script src='https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js'></script>
<script>
  const CommonHead ={
    template: `
      <div>
        公共头部组件
        <h3> {{ title }} </h3>
        <h4> {{ sub_title }} </h4>
      </div>
    `
    // properties  怎么接收
    ,props: ['title', 'sub_title']
  }
  const Home = {
    template: "#tpl"
    ,components: {
      CommonHead
    }
    ,data() {
      return {
        homeTitle: '我是data定义的hemo标题'
      }
    }
  }
  const News = {
    template: "#tpl2"
    ,components: {
      CommonHead
    }
  }
  Vue.component("Home", Home)
  Vue.component("News", News)
  const app = new Vue({
    el: '#app'
    ,data: {
      msg: 'Hello Vue'
    }
  })
</script>
</body>
</html>